﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;//命名空间

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string constr = "server=.;uid=sa;pwd=123456;database=E_mar";
            SqlConnection sqlConnection = new SqlConnection(constr);
          
            try
            {
                sqlConnection .Open();
                Console.WriteLine("数据库已经打开");
                string sql = "select * form UCinfo";
                SqlCommand mycom = new SqlCommand(sql,sqlConnection);
                mycom.CommandTimeout = 2;
                Console.WriteLine("创建对象成功");
  
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }
            finally
            {
                sqlConnection .Close();
            }
        }
    }
}
